class Solution {
public:
    int numWaterBottles(int numBottles, int numExchange) {
        int a = numBottles / numExchange, b = numBottles % numExchange, ret = numBottles + a;
        while (a + b >= numExchange) {
            int tmp = a + b;
            ret += tmp / numExchange;
            a = tmp / numExchange;
            b = tmp % numExchange;
        }
        return ret;
    }
};